﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class NhanVienBUS
    {
        public static void INSERT(NhanVien D)
        {
            NhanVienDAL DAL = new NhanVienDAL();
            DAL.INSERT(D);
        }
        public static void UPDATE(NhanVien D)
        {
            NhanVienDAL DAL = new NhanVienDAL();
            DAL.UPDATE(D);
        }
        public static void UpdateTrangThai(string NhanVien, int TrangThai)
        {
            NhanVienDAL DAL = new NhanVienDAL();
            DAL.UpdateTrangThai(NhanVien, TrangThai);
        }
        public static void DELETE(string iD)
        {
            NhanVienDAL DAL = new NhanVienDAL();
            DAL.DELETE(iD);
        }
        public static NhanVienCollection GETALL()
        {
            NhanVienDAL DAL = new NhanVienDAL();


            int TotalRecords = 0;
            return DAL.GET("where 1=1", 0, 0,
                            NhanVienColumn.TenDangNhap_NhanVien.ToString(),
                            "ASC", out TotalRecords);
        }
        public static NhanVienCollection GET(string Where, int PageIndex, int PageSize, string OrderBy, string OrderDirection, out int TotalRecords)
        {
            NhanVienDAL DAL = new NhanVienDAL();
            return DAL.GET(Where, PageIndex, PageSize, OrderBy, OrderDirection, out TotalRecords);
        }
        public static NhanVien GetById(string iD)
        {
            int total = 0;
            NhanVienDAL DAL = new NhanVienDAL();
            NhanVienCollection NhanVienCollection = DAL.GET("where " + NhanVienColumn.TenDangNhap_NhanVien.ToString() + " = '" + iD.ToString() + "' ", 0, 0,
                NhanVienColumn.TenDangNhap_NhanVien.ToString(), "ASC", out total);
            if (NhanVienCollection.Count == 1)
                return NhanVienCollection[0];
            return null;

        }
    }
}
